# Contributor: J. Peter Mugaas <jpmugaas@suddenlink.net>

_realname=pdfrw
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.4
pkgrel=1
pkgdesc="Convert restructured text to PDF via reportlab (mingw-w64)"
arch=('any')
url='https://github.com/pmaupin/pdfrw'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=(${_realname}-${pkgver}.tar.gz::"https://github.com/pmaupin/${_realname}/archive/v${pkgver}.tar.gz")
sha256sums=('f4da059213a0fdf8f63aa3f711cfbc25a5100333514b396f71bb90cb7bd4365f')


prepare() {
  rm -rf python-build-${CARCH} | true
  cp -r "${_realname}-${pkgver}" "python-build-${CARCH}"
}

check() {
  msg "Python test for ${CARCH}"
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py check  
}

build() {
  cd ${srcdir}/python-build-${CARCH}
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/python-build-${CARCH}
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
